/**
 * sbx-scroll
 */
(function($) {
	$.fn.sbx = function() {
		var $this = $(this);

		return this.each(function() {
			$this.wrap('<div class="sbx"></div>');
			addControllers($this, $this.parent());
			$this.wrapInner('<div class="sbx-list"></div>')
		});
	};
	
	function addControllers($current, $parent) {
		var $item = $parent.find('#scroll div');
		
		$controller = function(selector) {
			return $parent.children().closest(selector);
		};
		
		$parent.prepend('<div class="controller left">&lt;</div>');
		$parent.append('<div class="controller right">&gt;</div>');
		$parent.append('<div class="clear"></div>');
		
		
		//window.console.log(controller.filter(".left"));
		
		$controller('.left').bind('click', function(e) {
			window.console.log($item);
			$item.animate({
				"margin-left": '-=55px'
			}, 500, function() {
				$item.css('display', 'none');
				window.console.log($item);
			});
			
		});
		
		$controller('.right').bind('click', function(e) {
			
		});
	}
	
})( jQuery );